<template>
	<view class="">

		<cl-cell-group title="消息设置" :titleStyle="{'margin-top': '50rpx'}">

<!-- 			<cl-cell title="开启通知" :isLink="false" :border="false">
				<template #value>
					<switch color="var(--color-primary)" checked style="transform:scale(0.8)" />
				</template>

				<template #label>建议开启，开启后您可以收到推送信息</template>
			</cl-cell>

			<cl-cell title="声音" :isLink="false" :border="false">
				<template #value>
					<switch color="var(--color-primary)" @change="setVoice"  :checked='setting.voiceStatus' style="transform:scale(0.8)" />
				</template>

				<template #label>建议开启，开启后收到消息时将会有声音</template>
			</cl-cell>

			<cl-cell title="震动" :isLink="false" :border="false">
				<template #value>
					<switch color="var(--color-primary)" @change="setVibrate" :checked='setting.vibrateStatus' style="transform:scale(0.8)" />
				</template>

				<template #label>建议开启，开启后收到消息时设备将会震动</template>
			</cl-cell> -->
			
			<cl-cell title="圆形头像" :isLink="false" :border="false">
				<template #value>
					<switch @change="setAvatar"  color="var(--color-primary)" :checked='setting.circleAvatar' style="transform:scale(0.8)" />
				</template>
			
				<template #label>开启后您的联系人头像将会变成圆形</template>
			</cl-cell>

		</cl-cell-group>

	</view>
</template>

<script>
	import {
		useloginStore
	} from '@/store/login'
	import pinia from '@/store/index'
	const loginStore = useloginStore(pinia)
	export default {
		data() {
			return {
				loginStore: loginStore,
				globalConfig: loginStore.globalConfig,
				setting: {
					voiceStatus: true,
					vibrateStatus: false,
					circleAvatar: false
				}
			}
		},
		created() {
			let setting = uni.getStorageSync('appSetting') ?? '';

			if (setting) {
				this.setting = setting;
			}

		},
		methods: {
			setVoice(e) {
				this.setting.voiceStatus = e.detail.value
				this.saveSet();
			},
			setVibrate(e) {
				this.setting.vibrateStatus = e.detail.value
				this.saveSet();
			},
			setAvatar(e) {
				this.setting.circleAvatar = e.detail.value
				this.saveSet();
			},
			saveSet() {
				loginStore.setAppSetting(this.setting)
			}
		}
	}
</script>

<style>

</style>